    //
//  AirlinesViewController.m
//  AirTicket
//
//  Created by imac.bmw on 10-12-23.
//  Copyright 2010 aircococ. All rights reserved.
//

#import "AirwaysViewController.h"


@implementation AirwaysViewController
@synthesize airwayArray;
@synthesize indexPathInTableView;
@synthesize delegate;
@synthesize codeArray;


- (id)initWithStyle:(UITableViewStyle)style {
	// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
	self = [super initWithStyle:UITableViewStylePlain];
	if (self) {
		// Custom initialization.
	}
	return self;
}

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)viewDidLoad {
	
	[super viewDidLoad];
	
	NSMutableDictionary *dic = [[NSMutableDictionary alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"airways" ofType:@"plist"]];
	self.airwayArray = [dic valueForKey:@"airways"];
	self.codeArray = [dic valueForKey:@"code"];
	
	[dic release];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
	return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
	return [airwayArray count];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
	
    
    cell.textLabel.text	= [airwayArray objectAtIndex:indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	
	NSString *airway = [airwayArray objectAtIndex:indexPath.row];
	NSString *code = [codeArray objectAtIndex:indexPath.row];
	[delegate didGetAirway:airway andCode:code atIndexPath:self.indexPathInTableView];
	
	[self.navigationController popViewControllerAnimated:YES];
}
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[indexPathInTableView release];
	[airwayArray release];
    [super dealloc];
}


@end
